package com.ckr.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

import javax.servlet.http.HttpServlet;

/**
 * @author Shadowckr
 * @create 2022-01-26 9:59
 */

@SpringBootApplication
@EnableEurekaClient //本服务启动之后会自动注册进Eureka中！
@EnableDiscoveryClient //服务发现
@EnableCircuitBreaker //对hystrix熔断机制的支持 【==========new=======】
public class DeptProviderHystrix8001 {
    public static void main(String[] args) {
        SpringApplication.run(DeptProviderHystrix8001.class, args);
    }

    //增加一个Servlet
    @Bean
    public ServletRegistrationBean<HttpServlet> hystrixMetricsStreamServlet() {
        ServletRegistrationBean<HttpServlet> registration = new ServletRegistrationBean<HttpServlet>(new HystrixMetricsStreamServlet());
        registration.addUrlMappings("/actuator/hystrix.stream");
        return registration;
    }
}
